package com.ruibang.glass.quality.component.subscriber;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.ruibang.glass.common.domain.quality.GlassBindTest;
import com.ruibang.glass.quality.service.impl.GlassStationServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Author: songJinKang
 * @CreateTime: 2024-05-09  14:28
 * @Description: TODO
 * @Version: 1.0
 */
@Slf4j
@Component
public class GlassBindTestMsgReceiver {

    /**
     * @Description: glass_bind_test消息处理
     * @version v1.0
     * @author songJinKang
     * @date 2024-05-09 14:27
     */
    public void receiveMessage(String message, String channel) {
        if (StringUtils.isNotBlank(message)) {
            GlassBindTest glassBindTest = JSON.parseObject(message, GlassBindTest.class);
//            log.error("glassBindTest ---实体---: " + message);
            if (glassBindTest != null && StringUtils.isNotBlank(glassBindTest.getNewID()) && StringUtils.isNotBlank(glassBindTest.getOldID())) {
                GlassStationServiceImpl.NEW_MAPPER_OLD_MAP.put(glassBindTest.getNewID(),glassBindTest.getOldID());
                GlassStationServiceImpl.OLD_MAPPING_NEW_MAP.put(glassBindTest.getOldID(),glassBindTest.getNewID());
            }
        }
    }

}
